package com.oss.enums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

/**
 * 权限类型枚举
 * @author chengqiang
 */
@Getter
public enum RightsTypeEnum {
    first(0,"一级菜单"),
    second(1,"二级菜单"),
    // 按钮
    button(2,"子级权限");
    @EnumValue
    private final Integer key;
    private final String desc;
    RightsTypeEnum(Integer key, String desc){
        this.key=key;
        this.desc=desc;
    }

    /**
     * 根据key获取枚举值
     * @param key 入参
     * @return 返回值
     */
    public static String getEnumDescByKey(Integer key){
        for (RightsTypeEnum item : RightsTypeEnum.values()) {
            if (item.getKey()==key) {
                return item.getDesc();
            }
        }
        return null;
    }
}
